import type {AxiosResponse} from "axios";
import request from "../../utils/request.ts";
import {message} from "antd";


// 查询所有 医生 名称
export const getAllDoctor = async (): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/doctor/doctornames')
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('查询所有医生名称失败')
        throw err
    }
}

// 查询所有 护士 名称
export const getAllNurse = async (): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/doctor/nursenames')
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('查询所有护士名称失败')
        throw err
    }
}

// 查询所有 医疗品 分类
export const getAllDrugs = async (): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/drugs/drugstype')
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('查询所有医疗品分类失败')
        throw err
    }
}


// 查询所有 科室 名称
export const getAllDepartment = async (): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/department/departnames')
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('查询所有科室名称失败')
        throw err
    }
}